new Vue({
  el: '#app',
  data() {
    return {
      form: {
        serachKey: "",
        page: 1,			//页数
        limit: 10			//每页数据条数
      },
      formData: {},
      tableData: [{}],		//表格数据
      total: 1,
      dialogForm: false,
      title: '',
      multipleSelection: []
    }
  },
  mounted() {
    this.getList1()
  },
  methods: {
    onSerach() {				//查询方法
      console.log("搜搜")
    },
    addContract() {
      console.log("跳转")
    },
    getList1() {
      let _this = this
      $.ajax({
        type: 'GET',
        data: { action: "jQueryAjax" },
        url: DomainName + '/ArticleUnit',
        success: function (data) {
          data = data.filter(function (item) {
            return item.Row_Status != '1'
          })
          _this.tableData = data;
          console.log(data)
        },
        dataType: "json"
      });
    },
    getList() {     //换页方法
      let _this = this
      $.ajax({
        type: 'POST',
        //	url: "../getContractListByConditionAction",
        url: "../getListByTableNameAction",
        data: {
          Data: "enterprise_info"
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        success: function (Result) {
          console.log(Result);
          _this.tableData = Result      //将获取的数据存到表格数据中
        },
        dataType: "json"
      });
    },
    addEnterprise() {
      window.location.href = './Add.html'
    },
    editMember(Article_Unit_SerialNumber) {
      console.log(Article_Unit_SerialNumber);
      sessionStorage.setItem("Article_Unit_SerialNumber", Article_Unit_SerialNumber)
      window.location.href = './Edit.html?Article_Unit_SerialNumber=' + Article_Unit_SerialNumber
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    deletMember(Article_Unit_SerialNumber) {
      this.$confirm('此操作将删除该栏目, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this.delete(Article_Unit_SerialNumber);
        this.getList1();
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    delete(Article_Unit_SerialNumber) {
      const _this = this
      $.ajax({
        url: DomainName + '/ArticleUnit_Original',
        type: 'GET',
        async: false,
        data: { action: "jQueryAjax" },
        success: function (res) {
          console.log(res);
          for (let i = 0; i < res.length; i++) {
            if (res[i].Article_Unit_SerialNumber == Article_Unit_SerialNumber) {
              res[i].Row_Status = '1'
              _this.detel = res[i];
            }
          }
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        }
      })
      let data = { Data: JSON.stringify({ Modify: { article_unit: [_this.detel] } }) };
      console.log(data);
      $.ajax({
        url: DomainName + '/GoodsFileEdit',
        type: 'POST',
        async: false,
        data: data,
        error: function () {
          _this.$message.error("删除失败，请稍后再试")
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        }
      })
    }
  },
})